//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.make.house.api.model;


public class JSONResult implements Bean {
    private int status;
    private String desc;
    private Object data;
    public static final JSONResult OK = okResult();
    public static final JSONResult NO_RESULT = noResult();

    public JSONResult() {
    }

    public JSONResult(ActionStatus actionStatus){
        this.status = actionStatus.inValue();
        this.desc = actionStatus.getDescription();
    }

    public JSONResult(int status, String desc, Object data) {
        this.status = status;
        this.desc = desc;
        this.data = data;
    }

    public int getStatus() {
        return this.status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getDesc() {
        return this.desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Object getData() {
        return this.data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static JSONResult.Builder newBuilder() {
        return new JSONResult.Builder();
    }

    public static JSONResult okResult(Object data) {
        return newBuilder().setData(data).setStatus(ActionStatus.NORMAL_RETURNED.inValue()).setDesc("ok").build();
    }

    public static JSONResult onResult(String desc) {
        return newBuilder().setStatus(ActionStatus.NORMAL_RETURNED.inValue()).setDesc(desc).build();
    }

    public static JSONResult okResult() {
        return okResult(null);
    }

    public static JSONResult paramErrorResult(String errMsg) {
        return newBuilder().setStatus(ActionStatus.PARAMAS_ERROR.inValue()).setDesc(errMsg).build();
    }

    public static JSONResult failureResult(String errMsg) {
        return newBuilder().setStatus(ActionStatus.SERVER_ERROR.inValue()).setDesc(errMsg).build();
    }

    public static JSONResult forbiddenResult(String errMsg) {
        return newBuilder().setStatus(ActionStatus.FORBIDDEN.inValue()).setDesc(errMsg).build();
    }

    public static JSONResult noResult() {
        return newBuilder().setStatus(ActionStatus.NO_RESULT.inValue()).setDesc(ActionStatus.NO_RESULT.getDescription()).build();
    }

    public static class Builder {
        private JSONResult result;

        private Builder() {
            this.result = new JSONResult();
        }

        public JSONResult.Builder setStatus(int status) {
            this.result.status = status;
            return this;
        }

        public JSONResult.Builder setDesc(String desc) {
            this.result.desc = desc;
            return this;
        }

        public JSONResult.Builder setData(Object data) {
            this.result.data = data;
            return this;
        }

        public JSONResult build() {
            return this.result;
        }
    }
}
